<?php
/*
 * @Descripttion: 
 * @Author: dedeye
 * @Date: 2020-02-27 12:43:10
 * @LastEditors: dedeye
 * @LastEditTime: 2020-02-28 21:40:00
 */

use think\migration\Migrator;
use think\migration\db\Column;

class Rule extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('rule', [
            'comment' => '目录信息'
        ])->setCollation('utf8mb4_general_ci');
        $table->addColumn('name', 'string', [
            'limit'   => 50,
            'default' => '',
            'comment' => '名称'
        ])->addColumn('fid', 'integer', [
            'limit'   => 11,
            'default' => 0,
            'comment' => '父级ID'
        ])->addColumn('url', 'string', [
            'limit'   => 50,
            'default' => '',
            'comment' => '链接'
        ])->addColumn('target', 'string', [
            'limit'   => 20,
            'default' => '_self',
            'comment' => '链接'
        ])->addColumn('hash', 'string', [
            'limit'   => 128,
            'default' => '',
            'comment' => '组标识'
        ])->addColumn('sort', 'integer', [
            'limit'   => 3,
            'default' => 200,
            'comment' => '排序'
        ])->addColumn('is_menu', 'boolean', [
            'limit'   => 1,
            'default' => 0,
            'comment' => '是否菜单'
        ])->addColumn('icon', 'string', [
            'limit'   => 50,
            'default' => '',
            'comment' => '菜单图标'
        ])->addColumn('status', 'boolean', [
            'limit'   => 1,
            'default' => 0,
            'comment' => '是否显示'
        ])->addColumn('create_time', 'integer', [
            'limit'   => 11,
            'default' => 0,
            'comment' => '创建时间'
        ])->addColumn('update_time', 'integer', [
            'limit'   => 11,
            'default' => 0,
            'comment' => '修改时间'
        ])->addIndex(['fid', 'url'])->create();
    }
}
